package net.coding.bamboo.wex.mq;

import com.google.common.collect.Lists;
import com.weihui.finance.fundmanage.domain.common.enums.LoanSnapshotStatus;
import com.weihui.finance.fundmanage.domain.model.LoanResult;
import com.weihui.finance.fundmanage.domain.model.LoanResultMessage;
import net.coding.bamboo.wex.mq.client.JmsOperationClient;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author : zenghua
 * @version : v0.1 SimpleClientTest.java
 * @since : 2017/7/13 10:55
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:wex/mq/applicationContext-client.xml")
@Transactional
public class SimpleClientTest {
    @Resource
    private JmsOperationClient jmsOperationClient;

//    @Value("${jms.message.debt.loan.destination}")
//    private String destination;

    @Test
    public void testSendLoanResult() {
        try {
            List<LoanResult> loanResultList = Lists.newArrayList();
            LoanResult loanResult = new LoanResult();
            loanResult.setPartnerId("12345");
            loanResult.setLoanNo("821055556446770");
            loanResult.setResult(LoanSnapshotStatus.COMPLETE.name());
            loanResultList.add(loanResult);

            LoanResultMessage loanResultMessage = new LoanResultMessage();
            loanResultMessage.setLoanResultList(loanResultList);
            jmsOperationClient.send("weihui.finance.debt.loanSuccessResultQueue", loanResultMessage);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
